interactive math *1200

Please click on ads to support us..

Python Code:

import sys
for i in range(int(input())):
    n,m = map(int,input().split())
    ans = [0]*m
    for j in range(n + n - 1):
        s = input()
        for k in range(len(s)):
            ans[k] ^= ord(s[k])
    ans = [chr(i) for i in ans]
    x = ''.join(ans)
    print(x)
    sys.stdout.flush()

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define vvi vector<vi>
#define int long long

void solve(){

int n,m;
cin>>n>>m;
n=(n<<1)-1;
char a[m+5];
char s[m+5];
rep(i,0,m){
    a[i]=0;
}
rep(i,0,n){

    cin>>s;
   
    rep(j,0,m){
        a[j]^=s[j];
    }
}
rep(i,0,m){
    cout<<a[i];
}
cout<<endl;
 
}
bool isprime(int n) {
bool is_prime = true;
if (n == 0 || n == 1) {
is_prime = false;
}
for (int i = 2; i <= n / 2; ++i) {
if (n % i == 0) {
is_prime = false;
break;
}
}
return is_prime;
}
int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--){
solve();
}
}


Comments

Submit
0 Comments
More Questions

1632C - Strange Test
673A - Bear and Game
276A - Lunch Rush
1205A - Almost Equal
1020B - Badge
1353A - Most Unstable Array
770A - New Password
1646B - Quality vs Quantity
80A - Panoramix's Prediction
1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera
776A - A Serial Killer
25B - Phone numbers
1633C - Kill the Monster
1611A - Make Even
1030B - Vasya and Cornfield
1631A - Min Max Swap
1296B - Food Buying
133A - HQ9+